#{extends '/template/main.html' /}
<!-- Removing search and results count filter -->
<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">充值套餐</h3>

        <div class="panel-options">
            <a href="/manage/recharge/RechargeComboCtrl/rechargeComboDetail">
                <button class="btn btn-success btn-icon">
                    <i class="fa-plus-square-o"></i>
                    <span>新建套餐</span>
                </button>
            </a>
        </div>
    </div>

    <div class="panel-body">
        <form method="get" id="searchForm" action="/manage/recharge/RechargeComboCtrl/rechargeComboList">
            <div style="margin-bottom: 20px;width:160px;float: left;">
                <input type="text" name="rechargeAmount" id="id_amount" class="form-control" style="width:150px" placeholder="充值金额" value="${rechargeAmount}">
            </div>
            <div style="margin-bottom: 20px;width:160px;float: left;">
                *{<input type="text" name="availableStatus" id="id_availableStatus" class="form-control" style="width:150px" placeholder="启用状态" value="${phone}">}*
                <select class="form-control" name="availableStatus" style="width:150px" data-style="btn-primary">
                    <option value="" #{if availableStatus == null } selected="true"#{/if}>---请选择---</option>
                    <option value="AVAILABLE" #{if availableStatus == models.constants.AvailableStatus.AVAILABLE } selected="true"#{/if}>启用</option>
                    <option value="FREEZE" #{if availableStatus == models.constants.AvailableStatus.FREEZE } selected="true"#{/if}>禁用</option>
                </select>

            </div>
        </form>
        <button class="btn btn-turquoise" id="searchBtn">开始检索</button>
        <table class="table table-bordered table-striped" id="example-2">
            <thead>
            <tr>
                <th class="no-sorting">
                    <input type="checkbox" class="cbr">
                </th>
                <th>充值金额</th>
                <th>赠送金额</th>
                <th>套餐类型</th>
                <th>启用状态</th>
                <th>操作</th>
            </tr>
            </thead>

            <tbody class="middle-align">
            #{paginate.list items:resultPage , as :'rechargeCombo'}
            <tr>
                <td>
                    <input type="checkbox" class="cbr">
                </td>
                <td>${rechargeCombo?.rechargeAmount}</td>
                <td>${rechargeCombo?.giveAmount}</td>
                <td>&{'GoodsType.' + rechargeCombo?.goodsType}</td>
                <td>${rechargeCombo?.availableStatus.toString()}</td>

                <td>
                    <a href="/manage/recharge/RechargeComboCtrl/rechargeComboDetail/${rechargeCombo?.id}/${pageNumber}" id="idBtnAvailable"  class="btn btn-success btn-sm btn-icon icon-left">编辑</a>
                    <a href="#" id="idBtnAvailable" onclick="disablaComfim(${rechargeCombo?.id} ,1);" class="btn btn-success btn-sm btn-icon icon-left">启用</a>
                    <a href="#" id="idBtnFreeze" onclick="disablaComfim(${rechargeCombo?.id} , 2);" class="btn btn-danger btn-sm btn-icon icon-left">禁用</a>

                </td>
            </tr>
            #{/paginate.list}

            </tbody>
        </table>
        <div id="layerPage" class="col-xs-12"></div>
    </div>
</div>



<!-- Imported styles on this page -->
<link rel="stylesheet" href="/public/js/datatables/dataTables.bootstrap.css">

<script src="/public/js/datatables/js/jquery.dataTables.min.js"></script>


<!-- Imported scripts on this page -->
<script src="/public/js/datatables/dataTables.bootstrap.js"></script>
<script src="/public/js/datatables/yadcf/jquery.dataTables.yadcf.js"></script>
<script src="/public/js/datatables/tabletools/dataTables.tableTools.min.js"></script>

<script type="text/javascript" src="/public/laypage/laypage.js"></script>
<script type="text/javascript">

    $(document).ready(function(){
        // 提示
        var msg = '${flash.get("msg")}';
        if(msg) {
            saveSuccess(msg);
        }

        // 分页
        laypage({
            cont: $('#layerPage'), //容器。值支持id名、原生dom对象，jquery对象,
            pages: '${resultPage?.pageCount}', //总页数
            skin: 'yahei',
            curr:'${pageNumber}',
            jump: function(e, first){ //触发分页后的回调
                if(!first){ //一定要加此判断，否则初始时会无限刷新
                    $('#pageNumber').val(e.curr);
                    $("#searchForm").attr("action", "/manage/recharge/RechargeComboCtrl/rechargeComboList/"+e.curr);
                    $('#searchForm').submit();
                }
            }
        });
        $(document).on("click", "#searchBtn", function(){
            $("#searchForm").attr("action", "/manage/recharge/RechargeComboCtrl/rechargeComboList/1");
            $('#searchForm').submit();
        })
    });


    //点击确认禁用 之后执行的方法
    function sureDisableConfirm() {
        var id = $('#operateId').val() ;
        var operateType = $('#operateType').val();
          var  url = '/manage/recharge/RechargeComboCtrl/availableCombo/' + id + '/${pageNumber}';
        if(operateType == 2)
            url = '/manage/recharge/RechargeComboCtrl/freezeCombo/' + id + '/${pageNumber}';

        document.location.href = url ;
    }


</script>


